import {useHistory} from "react-router-dom";
//展示退出按钮
function AuthButton() {
    let history = useHistory();
    console.log("history:");
    console.log(history);
    //获取 auth 对象，获取共享的 context 数据
    let auth = useAuth();
    return auth.user ? (
        <p>
            
            Welcome! {auth.user}
            <button onClick={e => {
                auth.signout(() => {
                    history.push("/");
                });
            }}>Log Out</button>
        </p>
    ) : (<p>You are not logged in.</p>)
}